package com.stupidzhe.ds;

import com.stupidzhe.ds.linkedlist.DoublyLinkedList;
import com.stupidzhe.ds.linkedlist.SimpleLinkedList;
import com.stupidzhe.ds.stack.SimpleQueue;
import org.junit.Test;

/**
 * @Author: StupidZhe
 * @Date: Created in 2018/3/27
 * @Description:
 */
public class TestMain {

    // 经典链表测试
    @Test
    public void listTest() {
        SimpleLinkedList<String> linkedList = new SimpleLinkedList<>();
        linkedList.add("1");
        linkedList.add("2");
        linkedList.add("3");
        linkedList.add("4");
        System.out.println(linkedList.delete("3"));
        System.out.println(linkedList.toString());
        for (String cont : linkedList) {
            System.out.println(cont);
        }
    }

    // 双向链表测试
    @Test
    public void dListTest() {
        DoublyLinkedList<String> linkedList = new DoublyLinkedList<String>();
        linkedList.add("1");
        linkedList.add("2");
        linkedList.add("3");
        linkedList.add("4");
        System.out.println(linkedList.delete("1"));
        System.out.println(linkedList.toString());
        for (String cont : linkedList) {
            System.out.println(cont);
        }
    }

    @Test
    public void queueTest() {
        SimpleQueue simpleQueue = new SimpleQueue(8);
        simpleQueue.enqueue(1);
        simpleQueue.enqueue(2);
        simpleQueue.enqueue(3);
        simpleQueue.enqueue(4);
        simpleQueue.enqueue(5);
        simpleQueue.enqueue(6);
        simpleQueue.enqueue(7);
        simpleQueue.enqueue(8);
        simpleQueue.enqueue(9);
        simpleQueue.enqueue(10);
        for (int n : simpleQueue) {
            System.out.println(n);
        }
    }
}
